Slide 17 / 41

A Key Application: Arithmetic Expressions

So far, we've learned about the theory of trees. But what are they actually used for? One of the most classic and powerful applications is representing and evaluating mathematical expressions.

Consider this simple expression:

( 3 + 4 ) * 5

Notice the nested structure. The `+` operation applies to `3` and `4`. The `*` operation then applies to the entire result of `(3 + 4)` and `5`.

This natural hierarchy is what makes a tree the perfect data structure to represent it.